#!C:\Python\Python36\Python.exe
# -*- coding:utf-8 -*-
#@Time  : 2020-01-15 10:37
#@Author: iceman
#@File  : test02case.py
import json
import unittest

import readConfig
from common import configHttp


class testwitwork(unittest.TestCase):
    """智慧工场API"""
    scheme = readConfig.ReadConfig().get_http('scheme')
    base = readConfig.ReadConfig().get_http('baseurl')
    headers = {
        "Connection": "keep-alive",
        "Accept": "application/json",
        "Content-Type": "application/x-www-form-urlencoded",
        "Connection": "keep-alive",
        "Accept-Language": "zh-CN",
        "X-Requested-With": "XMLHttpRequest",
        "Referer": "a",
        "Content-Length": "18",
        "Host": "test-witwork.yiqijiao.net",
        "User-Agent": "Apache-HttpClient/4.5.6 (Java/1.8.0_131)",
    }

    def get_login(self):
        """登录：http://test-witwork.yiqijiao.net/api/session/tests"""
        data = "mobile=18215555153"
        path = "/api/session/tests"
        url = self.scheme + "://" + self.base + path
        info = configHttp.RunMain().run_main('post', url, data,headers=self.headers)
        self.assertIn("success",info)

    def get_config(self):
        """获取配置：http://test-witwork.yiqijiao.net/api/v2/config/properties"""
        path = "/api/v2/config/properties"
        url = self.scheme + "://" + self.base + path
        info = configHttp.RunMain().run_main('get',url,data=None,headers=self.headers)
        self.assertIn("seasons",info)